package com.controller;

import com.model.MyUser;
import com.service.MyUserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.yaml.snakeyaml.events.Event;

import java.util.List;

@Api(tags = "我的用户")
@RestController
@RequestMapping("/myUser")
public class MyUserController {

    @Autowired
    private MyUserService myUserService;

    @RequestMapping(value = "/addUser", method = RequestMethod.GET)
    public int addUser(MyUser myUser){
        System.out.println("进入用户添加方法");
        return myUserService.addMyUser(myUser);
    }

    @RequestMapping(value = "/updateMyUser", produces = "application/json;charset=utf-8", method = RequestMethod.GET)
    public int updateUser(MyUser myUser){
        System.out.println("进入用户修改方法，修改的主键为+"+ myUser.getID());
        return myUserService.updateMyUser(myUser);
    }

    @RequestMapping(value = "/deleteMyUser", method = RequestMethod.GET)
    public int deleteMyUser(int ID){
        System.out.println("进入删除用户信息，主键为："+ ID);
        return myUserService.deleteMyUser(ID);
    }

    @RequestMapping(value = "/getUser", produces = "application/json;charset=utf-8", method = RequestMethod.GET)
    public MyUser getUser(int ID){
        System.out.println("进入根据主键查找用户信息，主键为："+ ID);
        return myUserService.getUser(ID);
    }

    @RequestMapping(value = "/getAll", produces = "application/json;charset=utf-8", method = RequestMethod.PUT)
    public List<MyUser> getAll(MyUser myUser){
        System.out.println("进入用户查询方法");
        return myUserService.getAllMyUsers(myUser);
    }

}

